package com.zwh.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//import org.springframework.web.filter.CorsFilter;

import com.zwh.filter.CorsFilter;

import java.util.List;

/**
 * @author zwh
 * @date 2021/8/5 17:29
 **/
@Configuration
public class FilterConfig {

//    @Bean
//    public CorsFilter corsFilter() throws Exception {
//        return new CorsFilter();
//    }

    @Bean
    public FilterRegistrationBean setAuthenticationFilter(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new CorsFilter());
        filterRegistrationBean.setOrder(-105 + 1);   //order的数值越小，在所有的filter中优先级越高
        return filterRegistrationBean;
    }
}
